home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 08 - 1992 / 08.05 Sep 92 / Getting Started / C Version / PICTWindow.c next >
Encoding:
C/C++ Source or Header  |  1992-07-21  |  1.3 KB  |  84 lines  |  [TEXT/KAHL]

  1. #define kBaseResID            128
  2. #define    kMoveToFront        (WindowPtr)-1L
  3.  
  4.  
  5. /***************/
  6. /*  Functions  */
  7. /***************/
  8.  
  9. void    ToolBoxInit( void );
  10. void    WindowInit( void );
  11. void    DrawMyPicture( void );
  12.  
  13.  
  14. /****************** main ***************************/
  15.  
  16. void    main( void )
  17. {
  18.     ToolBoxInit();
  19.     WindowInit();
  20.     
  21.     DrawMyPicture();
  22.     
  23.     while ( !Button() ) ;
  24. }
  25.  
  26.  
  27. /****************** ToolBoxInit *********************/
  28.  
  29. void    ToolBoxInit( void )
  30. {
  31.     InitGraf( &thePort );
  32.     InitFonts();
  33.     InitWindows();
  34.     InitMenus();
  35.     TEInit();
  36.     InitDialogs( nil );
  37.     InitCursor();
  38. }
  39.  
  40.  
  41. /****************** WindowInit ***********************/
  42.  
  43. void    WindowInit( void )
  44. {
  45.     WindowPtr    window;
  46.     
  47.     window = GetNewWindow( kBaseResID, nil, kMoveToFront );
  48.     
  49.     if ( window == nil )
  50.     {
  51.         SysBeep( 10 );    /*  Couldn't load the WIND resource!!!  */
  52.         ExitToShell();
  53.     }
  54.     
  55.     ShowWindow( window );
  56.     SetPort( window );
  57. }
  58.  
  59.  
  60. /****************** DrawMyPicture ********************/
  61.  
  62. void    DrawMyPicture( void )
  63. {
  64.     Rect            pictureRect;
  65.     PicHandle    picture;
  66.     
  67.     picture = GetPicture( kBaseResID );
  68.     
  69.     if ( picture == nil )
  70.     {
  71.         SysBeep( 10 );    /*  Couldn't load the PICT resource!!!  */
  72.         ExitToShell();
  73.     }
  74.     
  75.     pictureRect = (**picture).picFrame;
  76.     
  77.     OffsetRect( &pictureRect, - pictureRect.left,
  78.                     - pictureRect.top );
  79.     
  80.     DrawPicture( picture, &pictureRect );
  81.     
  82.     FrameRect( &pictureRect );
  83. }
  84.